package exception_demo;

/**
 * @author ChenYongHao
 * @date 2023/4/28 9:33
 * @desc
 */
// 自定义异常类
class ScoreException extends Exception {
    public ScoreException() {}

    public ScoreException(String message) {
        super(message);
    }
}

class Teacher {
    public void checkScore(int score) throws ScoreException {
        if (score < 0 || score > 100) {
            throw new ScoreException("你给的成绩有误，分数应该在0-100之间");
        } else {
            System.out.println("你给的成绩正常");
        }
    }
}

class Main {
    public static void main(String[] args) {
        try {
            Teacher s = new Teacher();
            s.checkScore(120);
        } catch (ScoreException e) {
            e.printStackTrace();
        }
    }
}
